﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
namespace ERP.Classes
{
    public class cs_erp_ht_ttInfo
    {
        private int _id_httt;
        private string _ten_httt;

        public cs_erp_ht_ttInfo()
        {
            this._id_httt = 0;
            this._ten_httt = " ";

        }
        public int id_httt
        {
            get
            {
                return this._id_httt;
            }
            set
            {
                this._id_httt = value;
            }
        }
        public string ten_httt
        {
            get
            {
                return this._ten_httt;
            }
            set
            {
                this._ten_httt = value;
            }
        }

        public int ExcuteStoreProcedure(string storeProcedure, int option)
        {
            string[] paraName = new string[3];
            paraName[0] = "@id_httt";
            paraName[1] = "@ten_httt";
            paraName[2] = "@option";
            object[] paraValue = new object[3];
            paraValue[0] = this._id_httt;
            paraValue[1] = this._ten_httt;
            paraValue[2] = option;
            csCSDL csdl = new csCSDL();
            int i = 0;
            i = csdl.CreateParameters(paraName, 3, paraValue);
            return csdl.ExcuteStoreProcedure(storeProcedure);
        }
        public int ExcuteProcedure(int option)
        {
            return this.ExcuteStoreProcedure("Proc_ERP_HT_TT", option);
        }

        public int Get_Info()
        {
            csCSDL csdl = new csCSDL();
            DataSet ds = new DataSet("ds");
            try
            {
                ds = csdl.OpenTable("ERP_HT_TT", "id_httt = " + this._id_httt);
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    return 0;
                }
                this._id_httt = Convert.ToInt32(ds.Tables[0].Rows[0]["id_httt"].ToString().Trim());
                this._ten_httt = ds.Tables[0].Rows[0]["ten_httt"].ToString().Trim();
                return 1;
            }
            catch
            {
                return -1;
            }
        }
        public DataSet Get_List()
        {
            csCSDL csdl = new csCSDL();
            DataSet ds = new DataSet("ds");
            try
            {
                string sql = "select id_httt, ten_httt "
                + " from ERP_HT_TT order by id_httt asc";
                ds = csdl.SelecSQL(sql);

                return ds;
            }
            catch
            {
                return null;
            }
        }
    }
}